﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Touchscreen
{
    public partial class Stap3 : System.Web.UI.Page
    {
        public const string ImageFolder = "~/App_Themes/Images/";
        public const string FlagsFolder = "~/App_Themes/Images/Flags/";

        public string FilmName;
        public int AdultCounter;
        public int ChildCounter;
        public int OldPeopleCounter;
        public int StudentCounter;
        public int GlassesCounter;
        public double TotalPrice;

        List<TicketType> tickets;

        protected void Page_Load(object sender, EventArgs e)
        {
            FilmName = Request.QueryString["FilmName"];
            AdultCounter = Convert.ToInt32(Request.QueryString["Adult"]);
            ChildCounter = Convert.ToInt32(Request.QueryString["Child"]);
            OldPeopleCounter = Convert.ToInt32(Request.QueryString["OldPeople"]);
            StudentCounter = Convert.ToInt32(Request.QueryString["Student"]);
            GlassesCounter = Convert.ToInt32(Request.QueryString["3D"]);

            ButtonPrevious.PostBackUrl = "Stap2.aspx?FilmName=" + FilmName +
                                            "&Adult=" + AdultCounter +
                                            "&Child=" + ChildCounter +
                                            "&OldPeople=" + OldPeopleCounter +
                                            "&Student=" + StudentCounter +
                                            "&3D=" + GlassesCounter;

            LabelNumberAdult.Text = AdultCounter + " x";
            LabelNumberChild.Text = ChildCounter + " x";
            LabelNumberOldPeople.Text = OldPeopleCounter + " x";
            LabelNumberStudent.Text = StudentCounter + " x";
            LabelNumber3D.Text = GlassesCounter + " x";



            TicketManager ticketManager = new TicketManager();
            tickets = ticketManager.GetTicketTypes();
            // Moet nog aangepast worden zodat het dynamisch word gevuld in de tabel.
            LabelTypeAdult.Text = tickets[0].ticketName;
            LabelTypeChild.Text = tickets[1].ticketName;
            LabelTypeOldpeople.Text = tickets[2].ticketName;
            LabelTypeStudent.Text = tickets[3].ticketName;
            LabelType3D.Text = tickets[4].ticketName;


            double TotalPriceAdult = Convert.ToDouble(tickets[0].ticketPrice) * AdultCounter;
            double TotalPriceChild = Convert.ToDouble(tickets[1].ticketPrice) * ChildCounter;
            double TotalPriceOldPeople = Convert.ToDouble(tickets[2].ticketPrice) * OldPeopleCounter;
            double TotalPriceStudent = Convert.ToDouble(tickets[3].ticketPrice) * StudentCounter;
            double TotalPrice3d = Convert.ToDouble(tickets[4].ticketPrice) * GlassesCounter;
            TotalPrice = TotalPriceAdult + TotalPriceChild + TotalPriceOldPeople + TotalPriceStudent + TotalPrice3d;


            LabelPriceAdult.Text = " &euro; " + String.Format("{0:0.00}", TotalPriceAdult);
            LabelPriceChild.Text = "&euro; " + String.Format("{0:0.00}", TotalPriceChild);
            LabelPriceOldPeople.Text = "&euro; " + String.Format("{0:0.00}", TotalPriceOldPeople);
            LabelPriceStudent.Text = "&euro; " + String.Format("{0:0.00}", TotalPriceStudent);
            LabelPrice3d.Text = "&euro; " + String.Format("{0:0.00}", TotalPrice3d);

            LabelPriceTotal.Text = "Totaal: &euro; " + String.Format("{0:0.00}", TotalPrice);
        }

        protected void ButtonPrevious_Click(object sender, EventArgs e)
        {

        }

        protected void ButtonNext_Click(object sender, EventArgs e)
        {
            ButtonNext.PostBackUrl = "Stap4.aspx?FilmName=" + FilmName +
                                    "&Adult=" + AdultCounter +
                                    "&Child=" + ChildCounter +
                                    "&OldPeople=" + OldPeopleCounter +
                                    "&Student=" + StudentCounter +
                                    "&3D=" + GlassesCounter +
                                    "&Prijs=" + TotalPrice;
        }
    }
}